package exercise;

public class TapWaterTest {
	public static void main(String[] args) {
		TapWater tap1=TapWater.getTapWater();
		TapWater tap2=TapWater.getTapWater();
		TapWater tap3=TapWater.getTapWater();
		System.out.println(tap1.hashCode());
		System.out.println(tap2.hashCode());
		System.out.println(tap3.hashCode());
		tap1.decrease(2);
		tap2.decrease(2);
		tap3.decrease(2);
		System.out.println(tap1.getSurplus());
	}

}
class TapWater{
	private int surplus;
	static TapWater sc=null;
	public static TapWater getTapWater(){
		if(sc==null)
			sc= new TapWater();
		return sc;
	}
	public void decrease(int lose){
		surplus-=lose;
	}
	private TapWater(){
		this(20);
	}
	private TapWater(int surplus){
		this.surplus=surplus;
	}
	public  int getSurplus() {
		return surplus;
	}
	public  void setSurplus(int surplus) {
		this.surplus = surplus;
	}
}
